package use_case.handlereturns;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;

import use_case.processRental.Items;

public class Storage {

	ArrayList<itemDescription> shelf = new ArrayList<itemDescription>();
	private int shelfSize;
	
	public Storage( )
	{
		this( 10 );
	}
	
	public Storage(int shelfSize)
	{
		this.shelfSize = shelfSize;
	}
	
	public itemDescription getItem(int index)
	{
		return shelf.get(index);
	}
	
	public String[] getListEntries()
	{
		String[] listNames = new String[shelf.size()];
		for (int i = 0; i < shelf.size(); i++) {
        	listNames[i]= shelf.get(i).getName();
        }
		
		return listNames;
	}
	
	public int getSize(){return shelf.size();}
	
	public void initialize()
	{
		Random generator = new Random((new Date()).getTime());
		addItem(new DVD("A-Team", "Action", generator.nextInt(100000)));
		addItem(new Game("Starcraft", "Strategy",generator.nextInt(100000)));
		addItem(new DVD("Batman", "Action", generator.nextInt(100000)));
		addItem(new DVD("SuperBad", "Comedy", generator.nextInt(100000)));
		addItem(new DVD("Guild Wars", "RPG", generator.nextInt(100000)));
	}
	
	public boolean addItem(itemDescription item){
		if(shelf.size() < shelfSize)
		{
			shelf.add(item);
			return true;
		}
		
		return false;
	}
	
	public void printItems(){
		
		for(int i = 0; i< shelf.size(); i++){
			System.out.println(shelf.get(i).getID());
		}
	}
	
	public void removeItem(itemDescription item){
		shelf.remove(item);
	}
	
	public void displayItems()
	{
		 // Print Object content
        for (int i = 0; i < shelf.size(); i++) {
        	System.out.println((i+1) +"\t"+ shelf.get(i).getName());
        }
	}
		
		
}
